public class Demo05 {
    public static void main(String[] args) {
        System.out.println("--");

        String str=" dsfds-fdfhh-hhhty.jpg    ";
        System.out.println(str.length());  //length()字符串的长度 字符的总个数
        str=str.trim();//trim() 去掉两端空格
        System.out.println(str.length());
        boolean s1=str.startsWith("ds");  //startsWith:判断是否以指定的参数开头
        System.out.println("s1:"+s1);
        boolean s2=str.endsWith(".txt");//endsWith:判断是否以指定的参数结尾
        System.out.println("s2:"+s2);

        int firstIndex= str.indexOf("f");
        int lastIndex=str.lastIndexOf("f");
        System.out.println("firstIndex:"+firstIndex);
        System.out.println("lastIndex:"+lastIndex);
        System.out.println("---------------------------------------------------");
         char ch=str.charAt(2);
        System.out.println(ch);
        String str1="我爱祖国，祖国是我们大家心中的最美";
        for (int i=0;i<str1.length();i++){
             char ch1= str1.charAt(i);
             if (str1.indexOf(ch1) !=str1.lastIndexOf(ch1)){
                 System.out.println(ch1);
             }
        }


         boolean s3=str1.contains("祖国1");  //判断字符串中是否包含指定的子串
        System.out.println("s3:"+s3);
        String sss= str1.substring(2,7);  //字符串截取
        System.out.println(sss);

         String[] strs=str.split("-");
         System.out.println(strs);

         str= str.replace("-","");
        System.out.println(str);


    }
}
